package jackson.src.day02;

/*
 * Author: JacksonCoder
 * FileName: TaxGames
 * Version: 1.0.0
 */
public class TaxGames {
    public static void main(String[] args) {
        //  给一个有普通收入、工资收入和享受国务院特殊津贴的小伙伴算tax
        Income[] incomes = new Income[]{
                new Income(3000),
                new Salary(7500),
                new StateCouncilSpecialAllowance(5000)
        };
        System.out.println(totalTax(incomes));
    }

    public static double totalTax(Income... incomes){
        double total = 0;
        for(Income income: incomes){
            total += income.getTax();
        }
        return total;
    }
}

class Income {
    protected double income;

    public Income(double income){
        this.income = income;
    }

    public double getTax(){
        return income * 0.1;
    }

}

class Salary extends Income{
    public Salary(double income){
        super(income);
    }

    @Override
    public double getTax(){
        if(income <= 5000){
            return 0;
        }
        return (income - 5000) * 0.1;
    }
}

class StateCouncilSpecialAllowance extends Income{
    public StateCouncilSpecialAllowance(double income){
        super(income);
    }

    @Override
    public double getTax(){
        return 0;
    }
}